﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Json.WindowsPhone;

namespace
#if WINDOWS_PHONE
    PServiceBus.WindowsPhone
#else
 PServiceBus.Silverlight
#endif 
{
    internal static class JsonExtension {
        private static JavaScriptSerializer _serializer = new JavaScriptSerializer();
        public static string ToJson(this object value) {
            return _serializer.Serialize(value);
        }
        public static object FromJson(this string value) {
            return _serializer.DeserializeObject(value);
        }
        public static object FromJson(this string value, Type type) {
            return _serializer.Deserialize(value, type);
        }
        public static T FromJson<T>(this string value) {
            return _serializer.Deserialize<T>(value);
        }
    }
}
